package com.library.books.domain.vo.print;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Package: com.library.books.domain.vo.print
 * @ClassName: PrintTimestampGroupRecordVo
 * @Author: Yin
 * @Date: 14:15
 * @Description: 时间戳分组打印记录
 */
@Data
public class PrintTimestampGroupRecordVo {

    /** 本组内的打印id */
    private List<Long> printIds;

    /** 打印时间戳 */
    private Long printTimestamp;

    /** 打印时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date printTime;

    /** 打印次数 */
    private Long printNum;

    /** 打印状态 */
    private String printStatus;

    /** 操作人 */
    private String createBy;

    @JsonIgnore
    private String printIdGroup;

    public void setPrintTimestamp(Long printTimestamp) {
        this.printTimestamp = printTimestamp;
        this.printTime = new Date(printTimestamp);
    }

    public void setPrintIdGroup(String printIdGroup) {
        this.printIdGroup = printIdGroup;
        this.printIds = printIdGroup == null?null:Arrays.stream(printIdGroup.split(",")).map(Long::parseLong).collect(Collectors.toList());
    }
}
